<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>中昊供应链-智慧物流</title>
    <link href="imgs/icon_small.png" type="image/x-icon" rel="shortcut icon">

    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
</head>
<style>
    * {
        margin: 0;
        padding: 0;
    }

    html,
    body {
        width: 100%;
        height: 100%;
        font-size: 1.8rem;
        position: relative;
    }

    .main,
    .guide {
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        overflow: hidden;
    }

    .guide {
        background-color: #818689e8;
        position: absolute;
        top: 0;
        left: 0;
    }

    .guide img {
        width: 100%;
        height: 100%;
    }

    .main .logo {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding-top: 10rem;
    }

    .main .logo img {
        width: 15rem;
        height: 15rem;
    }

    .main .logo p {
        font-weight: bold;
        font-size: 2rem;
        margin-top: 1rem;
    }

    .main .desc {
        padding-top: 2rem;
        width: 87%;
        text-align: center;
        color: #666;
        font-size: 1.5rem;
    }

    .main .btn {
        background-color: #3f69d9;
        border: none;
        width: 20rem;
        height: 5rem;
        font-size: 2rem;
        color: #fff;
        border-radius: 2.5rem;
        margin-top: 4rem;
    }
</style>

<body>
    <div class="main">
        <div class="logo">
            <img class="logoUrl" src="" alt="">
            <p class="title">
                <!-- 中昊供应链 -->
            </p>
        </div>
        <div class="desc">
            <!-- 中昊供应链是一款拥有海量货主和司机的网络货运平台。这里可以接单、发货 -->
        </div>
        <input type="button" value="立即下载" class="btn">
    </div>
    <div class="guide" style="display: none;">
        <img src="./imgs/guide.png" alt="">
    </div>

    <script src="./jquery.min.js"></script>
    <script>
        var u = navigator.userAgent;
        var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //安卓终端
        var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
        var linkUrl = '';//下载地址链接
        //引导页元素
        var guide = document.querySelector(".guide");
        //立即下载按钮元素
        var btn = document.querySelector('.btn');
        //添加响应式监听 用于监听尺寸变化修改字体大小比值
        window.addEventListener("resize", setRem);
        setRem();

        let serach = location.search.slice(1);
        if (serach) {
            let list = location.search.slice(1).split('&');
            list.forEach(item=>{
                if(item.indexOf("url") != -1){
                    let url = decodeURIComponent(item.split('=')[1]);
                    location.href = url;
                }
            })
    
        }

        $.ajax({
            async: false,
            url: 'https://api.zhgylgl.com/api/config/appDownInfo',
            type: 'post',
            success: (res) => {
                res = JSON.parse(res)
                if (res.code == 200) {
                    //安卓
                    // location.href = `zhonghao://appdown?main_id=${main_id}&action=waybill`

                    $('.logo .logoUrl').attr('src', res.data.applogo);
                    $('.desc').text(res.data.appdesc);
                    $('.logo .title').text(res.data.appname);
                    linkUrl = isIOS ? res.data.ios : res.data.android
                }
            }
        })

        guide.addEventListener('click', () => {
            guide.style.display = 'none'
        })

        btn.addEventListener("click", () => {
            if (is_weixin()) {
                guide.style.display = 'block'
                return;
            }
            window.location.href = linkUrl;
        })

        //响应式
        function setRem() {
            //设计尺寸375 以iphone8尺寸为准
            let size = 375;
            let clientWidth = document.body.clientWidth;
            //获取当前页面比值 用于设置字体大小
            let rate = clientWidth / 375;
            document.documentElement.style.fontSize = (rate * 10 > 12 ? 12 : rate * 10) + 'px';
        }

        //是否为微信浏览器 当为微信浏览器时显示引导图片
        function is_weixin() {
            var ua = window.navigator.userAgent.toLowerCase();
            if (ua.match(/MicroMessenger/i) == 'micromessenger') {
                return true;
            } else {
                return false;
            }
        }
    </script>
</body>

</html>